package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.d_c.service.BuyCartService;
import com.zr.d_c.serviceimpl.BuyCartServiceImpl;
/**
 * 修改购物车中的菜品数量
 * @author Administrator
 *
 */
public class ModifyBuyCartController extends HttpServlet {

	BuyCartService buycartservice = new BuyCartServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter pw = resp.getWriter();
		String bidstr = req.getParameter("bid");
		String bnumstr = req.getParameter("bnum");
		int bid = 0;
		int bnum = 0;
		try{
			bid = Integer.parseInt(bidstr);
			bnum = Integer.parseInt(bnumstr);
		}catch(NumberFormatException e){
			pw.write("0");
		}
		if(buycartservice.modifyBuyCartByBid(bnum, bid)>0){
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.close();
		
	}
}
